
* dispmac.hs ... In-line Serial Display Driver
* ============================================

************************************************************************
*                                                                      *
*                  Copyright Hewlett-Packard Co. 1991                  *
*                                                                      *
************************************************************************

************************************************************************
*                                                                      *
*  DISPLAY is a MACRO that is used to output a string to the IQ display*
*  using the serial interface and *NO* RAM.  It is intended for use by *
*  routines like POWERON or FATALERROR where either the FPGA is not    *
*  loaded yet, or you need to get a message out (like RAM FAILURE)     *
*  using the minimum of system resources.                              *
*                                                                      *
*  DISPLAY is invoked after loading A0 with the address of the message *
*  string (eg: lea.l  MSG).  The message string can be any length and  *
*  terminates with a $00.  It is suggested that the string start with  *
*  either a $0E (clear) or $1B49 (esc I ... Initialize display).       *
*                                                                      *
*  DISPLAY trashes A0, D0, and D1.  If the display hardware is hung,   *
*  the macro times out and returns in about 50 msec.                   *
*                                                                      *
************************************************************************

DISPLAY         MACRO                           ;No parameters, A0 points to string.
                local           next,exit,wait

next            equ             *               ;Display next char
                cmpi.b          #$00,(A0)       ;String terminated by $00
                beq.s           exit

                move.w          #$7FFF,D1       ;Timeout value > 50 msec.

wait            subi.w          #1,D1           ;Timed out when D1 => 0
                bmi.s           exit

                move.w          #$0180,D0       ;See if serial transmitter is
                and.w           SCSR,D0         ;  still busy with last character.
                cmpi.w          #$0180,D0
                bne.s           wait

                subi.w          #$03A3,D1       ; adj outer loop for following 1.ms loop

                move.w          #$03A3,D0       ; VFdisplay busy bit needs 1.Ms setup
wait_min        subi.w          #1,D0           ; D0 goes to 0 in ~ 1.0 Msec 
                bpl.s           wait_min

                btst            #3,PACTL        ;See if display BUSY line PACTL.PCLKS
                bne.s           wait            ;  is still set (ie. busy)

                moveq           #0,D0
                move.b          (A0)+,D0        ;Output next character
                move.w          D0,SCDR
                ori.w           #$8,SCCR1       ;  and enable transmitter
                bra.s           next            ;Repeat.

exit            equ             *

                ori.b           #$80,QPDR       ;Force serial line high so power
                                                ;  flicker of display doesn't cause
                                                ;  test mode. (TXD = 1)
                ENDM

